package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collections;

final class zdu {
   static ArrayList a(zn var0, zbcq var1, com.aspose.cells.b.a.b.zp var2, float var3, double var4, int var6) throws Exception {
      com.aspose.cells.b.a.b.a.zf var7 = var0.e();
      com.aspose.cells.b.a.b.zq var8 = var0.f();
      var0.a(4);
      var0.a(var2);
      zig var9 = var1.v();
      int var10 = var1.ag();
      zbp var11;
      zbp var12;
      if (var10 == 1) {
         var12 = var9.e();
         var11 = var9.G();
      } else {
         var12 = var9.g();
         var11 = var9.I();
      }

      zbcs var13 = var9.z();
      int var14 = var13.getCount();
      double var15 = var11.n() ? var11.g(var11.D()) : var11.D();
      double var17 = var11.n() ? var11.g(var11.z()) : var11.z();
      var4 = var11.n() ? var11.g(var4) : var4;
      double var19 = var12.n() ? var12.g(var12.D()) : var12.D();
      double var21 = var12.n() ? var12.g(var12.z()) : var12.z();
      if (var12.n()) {
         var12.g(var12.x());
      } else {
         var12.x();
      }

      ArrayList var25 = new ArrayList();
      double var26 = (double)var2.e() / (var21 - var19);
      double var28 = a(var13, var15, var17, var19, var21);
      int var30 = var1.aj();
      zjg var31 = var1.E();

      for(int var32 = 0; var32 < var6; ++var32) {
         zje var33 = var31.b(var32);
         if (var33 != null && !var33.a() && !var33.b() && var33.v() <= var17 && var33.v() >= var15 && var33.q() <= var21 && var33.q() >= var19) {
            double var34 = (double)((float)var26) * (var33.q() - var19);
            if (var12.p()) {
               var34 = (double)(var2.c() + var2.e()) - var34;
            } else {
               var34 += (double)var2.c();
            }

            double var36 = (double)var3;
            double var38 = var33.v();
            double var40 = (var38 - var4) / (var17 - var15) * (double)var2.f();
            zsq var42 = var1.y();
            com.aspose.cells.b.a.b.zo var43 = new com.aspose.cells.b.a.b.zo((float)var34, var3);
            double var44 = 0.0D;
            double var46 = 0.0D;
            float var48 = 0.0F;
            float var49 = 0.0F;
            if (var42 != null) {
               switch(var42.g()) {
               case 0:
                  double var50 = var42.e().size() > var32 ? var42.a(var42.e().get(var32)) : 0.0D;
                  var44 = var50;
                  var50 = var42.f().size() > var32 ? var42.a(var42.f().get(var32)) : 0.0D;
                  var46 = var50;
                  break;
               case 1:
                  var44 = var42.c();
                  var46 = var44;
                  break;
               case 2:
                  var44 = var42.c() * var33.q() / 100.0D;
                  var46 = -var44;
               }

               var48 = (float)(var44 / (var21 - var19) * (double)var2.e());
               var49 = (float)(var46 / (var21 - var19) * (double)var2.e());
               if (!var11.p()) {
                  var43.b(var43.e() - (float)var40);
               } else {
                  var43.b(var43.e() + (float)var40);
               }
            }

            var42.a(var43, var48, var49);
            zsq var56 = var1.x();
            var44 = 0.0D;
            var46 = 0.0D;
            var48 = 0.0F;
            var49 = 0.0F;
            if (var56 != null) {
               switch(var56.g()) {
               case 0:
                  double var51 = var56.e().size() > var32 ? var56.a(var56.e().get(var32)) : 0.0D;
                  var44 = var51;
                  var51 = var56.f().size() > var32 ? var56.a(var56.f().get(var32)) : 0.0D;
                  var46 = var51;
                  break;
               case 1:
                  var44 = var56.c();
                  var46 = var44;
                  break;
               case 2:
                  var44 = var56.c() * var33.v() / 100.0D;
                  var46 = -var44;
               }

               var48 = (float)var44 / (float)(var17 - var15) * (float)var2.f();
               var49 = (float)var46 / (float)(var17 - var15) * (float)var2.f();
            }

            var56.a(var43, var48, var49);
            if (!var11.p()) {
               var36 -= var40;
            } else {
               var36 += var40;
            }

            com.aspose.cells.b.a.b.zo var57 = new com.aspose.cells.b.a.b.zo((float)var34, (float)var36);
            float var52 = 0.0F;
            float[] var53 = new float[]{var52};
            boolean var54 = a(var0, var57, var1, var33, var28, (int)a(var9.aj()), var53);
            var52 = var53[0];
            if (var54) {
               Object[] var55 = new Object[]{var30, var32, var57, var12};
               var33.a = var52;
               com.aspose.cells.b.a.a.ze.a(var25, (Object)var55);
            }
         }
      }

      var0.a(var7);
      return var25;
   }

   private static boolean a(zn var0, com.aspose.cells.b.a.b.zo var1, zbcq var2, zje var3, double var4, int var6, float[] var7) {
      double var10 = var3.B();
      float var12 = (float)var2.aa() / 100.0F;
      int var13 = var2.ac();
      boolean var14 = var2.ab();
      if (var10 == 0.0D) {
         return false;
      } else {
         if (var14) {
            var10 = Math.abs(var10);
         } else if (var10 < 0.0D) {
            return false;
         }

         double var15 = 0.0D;
         double var8;
         if (var13 == 0) {
            var15 = 3.141592653589793D * Math.pow((double)var6, 2.0D) / var4;
            var8 = Math.sqrt(var10 * var15 / 3.141592653589793D);
         } else {
            var15 = (double)(2 * var6) / var4;
            var8 = var10 * var15 / 2.0D;
         }

         var8 *= (double)var12;
         com.aspose.cells.b.a.b.zq var17 = new com.aspose.cells.b.a.b.zq(var1.d() - (float)var8, var1.e() - (float)var8, (float)zbuk.a((double)(2.0F * (float)var8)), (float)zbuk.a((double)(2.0F * (float)var8)));
         var3.a(new com.aspose.cells.b.a.b.zq(var1.d(), var1.e(), (float)var8, (float)var8));
         com.aspose.cells.b.a.b.a.ze var18 = new com.aspose.cells.b.a.b.a.ze();
         var18.a(var17);
         if (var3.i().h() != 0) {
            if (var3.B() > 0.0D) {
               var3.i().a(var18);
            } else {
               var0.a((com.aspose.cells.b.a.b.zc)(new com.aspose.cells.b.a.b.zu(Color.getWhite())), (com.aspose.cells.b.a.b.zq)var17);
            }
         }

         var3.k().a(var18);
         var7[0] = var17.h();
         return true;
      }
   }

   private static double a(zbcs var0, double var1, double var3, double var5, double var7) {
      double var9 = 0.0D;

      for(int var11 = 0; var11 < var0.getCount(); ++var11) {
         zbcq var12 = var0.c(var11);
         boolean var13 = var12.ab();
         if (var12.m() == 12 || var12.m() == 13) {
            zjg var14 = var12.E();

            for(int var15 = 0; var15 < var14.getCount(); ++var15) {
               zje var16 = var14.b(var15);
               if (var16 != null && !var16.a()) {
                  double var17 = var16.B();
                  if (var13) {
                     var17 = Math.abs(var17);
                  }

                  if (var9 < var17) {
                     var9 = var17;
                  }
               }
            }
         }
      }

      return var9;
   }

   static float a(com.aspose.cells.b.a.b.zt var0) {
      float var1 = var0.b() > var0.c() ? var0.c() : var0.b();
      return var1 / 8.0F;
   }

   static void a(boolean var0, zn var1, zbcs var2, com.aspose.cells.b.a.b.zp var3, int var4, boolean var5, boolean var6, boolean var7, boolean var8, boolean var9, boolean var10, boolean var11, boolean var12) throws Exception {
      zig var13 = var2.c(0).v();
      zbp var15 = var13.e();
      zbp var14 = var13.G();
      double var16 = var14.D();
      double var18 = var14.z();
      double var20 = var14.x();
      double var22 = var15.D();
      double var24 = var15.z();
      double var26 = var15.x();
      double var28 = (var24 - var22) / 2.0D;
      double var32 = (var18 - var16) / 2.0D;
      double[] var36 = new double[]{var28};
      double[] var37 = new double[]{var28};
      double[] var38 = new double[]{var32};
      double[] var39 = new double[]{var32};
      a(var2, var4, var36, var37, var38, var39);
      var28 = var36[0];
      double var30 = var37[0];
      var32 = var38[0];
      double var34 = var39[0];
      double var40 = (double)a(var13.aj());
      double var42 = var40 * (var24 - var22) / (double)var3.e();
      double var44 = var40 * (var18 - var16) / (double)var3.f();
      ArrayList var46;
      boolean var47;
      double var48;
      double var50;
      double var52;
      if (!var14.n()) {
         var46 = var14.l;
         var47 = false;
         if (var12 && var34 - var44 <= var16) {
            var16 = zbuk.a(var16, var20);
            com.aspose.cells.b.a.a.ze.a(var46, (Object)var16);
            var44 = var40 * (var18 - var16) / (double)var3.f();
            var47 = true;
         }

         if (var11 && var32 + var44 >= var18) {
            var18 = zbuk.b(var18, var20);
            var46.add(0, var18);
            var44 = var40 * (var18 - var16) / (double)var3.f();
            var47 = true;
         }

         if (var9 && var14.l.size() > 11) {
            var48 = var20 * 0.35D;
            if (var34 - var44 - (Double)var46.get(var46.size() - 1) < var48 || (Double)var46.get(0) - (var32 + var44) < var48) {
               var47 = true;
               var20 *= 2.0D;
               var50 = (Double)var46.get(0);
               var52 = (Double)var46.get(var46.size() - 1);
               double var54 = var20;
               int var56 = zbuk.g(var20);
               var46.clear();
               int var57 = a(var11, var12, var50, var52);
               double var58;
               if (var57 == 1) {
                  for(var58 = var50; var58 > var52 || zbuk.a(var52, var58) < var54; var58 -= var54) {
                     var58 = zbuk.a(var58, var56);
                     com.aspose.cells.b.a.a.ze.a(var46, (Object)var58);
                  }
               } else if (var57 == 2) {
                  var58 = var52;

                  while(true) {
                     if (var58 > var50 && zbuk.a(var58, var50) >= var54) {
                        Collections.reverse(var46);
                        break;
                     }

                     var58 = zbuk.a(var58, var56);
                     com.aspose.cells.b.a.a.ze.a(var46, (Object)var58);
                     var58 += var54;
                  }
               } else {
                  var58 = 0.0D;

                  label208:
                  while(true) {
                     if (var58 > var50 && zbuk.a(var58, var50) >= var54) {
                        Collections.reverse(var46);
                        var58 = 0.0D;

                        while(true) {
                           if (var58 <= var52 && zbuk.a(var52, var58) >= var54) {
                              break label208;
                           }

                           var58 = zbuk.a(var58, var56);
                           com.aspose.cells.b.a.a.ze.a(var46, (Object)var58);
                           var58 -= var54;
                        }
                     }

                     var58 = zbuk.a(var58, var56);
                     com.aspose.cells.b.a.a.ze.a(var46, (Object)var58);
                     var58 += var54;
                  }
               }
            }
         }

         if (var47) {
            if (var46.size() >= 2) {
               if (var11) {
                  var14.d((Double)var46.get(0));
               }

               if (var12) {
                  var14.f((Double)var46.get(var46.size() - 1));
               }

               if (var9) {
                  var14.c(var20);
               }

               if (var10) {
                  var14.e(var20 / 5.0D);
               }
            }

            zbr.a(var1, var14, var2.c(0), false);
         }
      }

      if (!var15.n()) {
         var46 = var15.l;
         var47 = false;
         if (var8 && var30 - var42 <= var22) {
            var22 = zbuk.a(var22, var26);
            com.aspose.cells.b.a.a.ze.a(var46, (Object)var22);
            var42 = var40 * (var24 - var22) / (double)var3.e();
            var47 = true;
         }

         if (var7 && var28 + var42 >= var24) {
            var24 = zbuk.b(var24, var26);
            var46.add(0, var24);
            var42 = var40 * (var24 - var22) / (double)var3.e();
            var47 = true;
         }

         if (var0) {
            double var49;
            int var60;
            if (var8) {
               var60 = zbuk.g(var26);
               if ((var30 - var42 - (var28 + var42)) / (var22 - (var28 + var42)) > 0.9523809523809523D) {
                  var49 = zbuk.a(var22 - var26, var60);
                  com.aspose.cells.b.a.a.ze.a(var46, (Object)var49);
                  var22 = var49;
                  var42 = var40 * (var24 - var49) / (double)var3.e();
                  var47 = true;
               }
            }

            if (var7) {
               var60 = zbuk.g(var26);
               if ((var28 + var42 - (var30 - var42)) / (var24 - (var30 - var42)) > 0.9523809523809523D) {
                  var49 = zbuk.a(var24 + var26, var60);
                  var46.add(0, var49);
                  var42 = var40 * (var49 - var22) / (double)var3.e();
                  var47 = true;
               }
            }
         }

         if (var5 && var46.size() > 11) {
            var47 = true;
            var26 *= 2.0D;
            var48 = (Double)var46.get(0);
            var50 = (Double)var46.get(var46.size() - 1);
            var52 = var26;
            int var61 = zbuk.g(var26);
            var46.clear();
            int var55 = a(var7, var8, var48, var50);
            double var62;
            if (var55 == 1) {
               for(var62 = var48; var62 > var50 || zbuk.a(var50, var62) < var52; var62 -= var52) {
                  var62 = zbuk.a(var62, var61);
                  com.aspose.cells.b.a.a.ze.a(var46, (Object)var62);
               }
            } else if (var55 == 2) {
               var62 = var50;

               while(true) {
                  if (var62 > var48 && zbuk.a(var62, var48) >= var52) {
                     Collections.reverse(var46);
                     break;
                  }

                  var62 = zbuk.a(var62, var61);
                  com.aspose.cells.b.a.a.ze.a(var46, (Object)var62);
                  var62 += var52;
               }
            } else {
               var62 = 0.0D;

               label161:
               while(true) {
                  if (var62 > var48 && zbuk.a(var62, var48) >= var52) {
                     Collections.reverse(var46);
                     var62 = 0.0D;

                     while(true) {
                        if (var62 <= var50 && zbuk.a(var50, var62) >= var52) {
                           break label161;
                        }

                        var62 = zbuk.a(var62, var61);
                        com.aspose.cells.b.a.a.ze.a(var46, (Object)var62);
                        var62 -= var52;
                     }
                  }

                  var62 = zbuk.a(var62, var61);
                  com.aspose.cells.b.a.a.ze.a(var46, (Object)var62);
                  var62 += var52;
               }
            }
         }

         if (var47) {
            if (var46.size() >= 2) {
               if (var7) {
                  var15.d((Double)var46.get(0));
               }

               if (var8) {
                  var15.f((Double)var46.get(var46.size() - 1));
               }

               if (var5) {
                  var15.c(var26);
               }

               if (var6) {
                  var15.e(var26 / 5.0D);
               }
            }

            zbr.a(var1, var15, var3, var3, var4, false, var2.c(0));
         }
      }

   }

   private static int a(boolean var0, boolean var1, double var2, double var4) {
      boolean var6 = true;
      byte var7;
      if (var0 && var1) {
         var7 = 3;
         if (var2 == 0.0D) {
            var7 = 2;
         }

         if (var4 == 0.0D) {
            var7 = 1;
         }
      } else if (!var0 && var1) {
         var7 = 1;
      } else if (var0 && !var1) {
         var7 = 2;
      } else {
         var7 = 2;
      }

      return var7;
   }

   private static void a(zbcs var0, int var1, double[] var2, double[] var3, double[] var4, double[] var5) {
      boolean var6 = false;
      boolean var7 = false;

      for(int var8 = 0; var8 < var0.getCount(); ++var8) {
         zjg var9 = var0.c(var8).E();

         for(int var10 = 0; var10 < var1; ++var10) {
            zje var11 = var9.b(var10);
            if (var11 != null && !var11.b()) {
               if (!var6) {
                  var2[0] = var11.q();
                  var3[0] = var2[0];
                  var6 = true;
               } else {
                  if (var11.q() > var2[0]) {
                     var2[0] = var11.q();
                  }

                  if (var11.q() < var3[0]) {
                     var3[0] = var11.q();
                  }
               }
            }

            if (var11 != null && !var11.a()) {
               if (!var7) {
                  var4[0] = var11.v();
                  var5[0] = var4[0];
                  var7 = true;
               } else {
                  if (var11.v() > var4[0]) {
                     var4[0] = var11.v();
                  }

                  if (var11.v() < var5[0]) {
                     var5[0] = var11.v();
                  }
               }
            }
         }
      }

   }
}
